package gameObjects;

import com.jme.renderer.ColorRGBA;
import com.jme.scene.state.MaterialState;
import com.jme.system.DisplaySystem;

public class Material {
	private ColorRGBA ambient;
	private ColorRGBA emissive;
	private ColorRGBA diffuse;
	private ColorRGBA specular;
	private float     shininess;
	private MaterialState ms;
	private DisplaySystem display;
	
	public Material()
	{
		this.display=DisplaySystem.getDisplaySystem();
		ms  		= this.display.getRenderer().createMaterialState();
		ambient   	= new ColorRGBA(0.5f, 0.5f, 0.5f,0.5f);
		emissive  	= new ColorRGBA(0.5f, 0.5f, 0.5f,0.5f);
		diffuse   	= new ColorRGBA(0.5f, 0.5f, 0.5f,0.5f);
		specular  	= new ColorRGBA(0.5f, 0.5f, 0.5f,0.5f);
		shininess 	= 64.0f;
	}
	
	public void setMaterial(ColorRGBA ambient,
									 ColorRGBA emissive,
									 ColorRGBA diffuse,
									 ColorRGBA specular,
									 Float     shininess)
	{
		this.ambient   = ambient;
		this.emissive  = emissive;
		this.diffuse   = diffuse;
		this.specular  = specular;
		this.shininess = shininess;
		setMaterial();
	}
	
	public void setMaterial(ColorRGBA color)
	{
		this.ambient   = color;
		this.emissive  = color;
		this.diffuse   = color;
		this.specular  = color;
		this.shininess = 64.0f;
		setMaterial();
	}
	
	private void setMaterial()
	{
		
		ms.setAmbient(this.ambient);
		ms.setEmissive(this.emissive);
		ms.setDiffuse(this.diffuse);
		ms.setSpecular(this.specular);
		ms.setShininess(this.shininess);
	}
	
	public MaterialState getMaterial()
	{
		return ms;
	}
}
